package HLLib.userControl;

import HLCode.HLClass;
import HLCode.HLClassManager;
import HLCode.HLClassManager_H;
import HLCode.HLObject;
import HLLib.base.HLImage;
import HLLib.base.HLList;
import HLLib.base.HLString;
import HLLib.io.HLFile;
import HLLib.io.HLPackage;

public class HLAchievementItem extends HLObject {
    public HLClass GetClass(HLClassManager classManager) {
        return classManager.GetLibClass(HLClassManager_H.CLASS_GROUP_TYPE_LIB_USERCONTROL, HLClassManager_H.LIB_CLASS_USERCONTROL_AchievementItem);
    }

    public int GetInt(int index) {
        switch (index) {
        case 0: {
            return score;
        }
        case 1: {
            return showLevel;
        }
        }
        return 0;
    }

    public void SetInt(int index, int value) {
        switch (index) {
        case 0: {
            score = value;
            return;
        }
        case 1: {
            showLevel = value;
            return;
        }
        }
    }

    public boolean GetBoolean(int index) {
        return isReach;
    }

    public void SetBoolean(int index, boolean value) {
        isReach = value;
    }

    public HLObject GetObject(int index) {
        switch (index) {
        case 0: {
            return name;
        }
        case 1: {
            return des;
        }
        case 2: {
            return value;
        }
        case 3: {
            return icon;
        }
        }
        return null;
    }

    public void SetObject(int index, HLObject value) {
        switch (index) {
        case 0: {
            name = (HLString) value;
            return;
        }
        case 1: {
            des = (HLString) value;
            return;
        }
        case 2: {
            value = (HLString) value;
            return;
        }
        case 3: {
            icon = (HLImage) value;
            return;
        }
        }
    }

    public static final int SHOW_NONE = 0;

    public static final int SHOW_NAME_ONLY = 1;

    public static final int SHOW_ALL = 2;

    public HLString name;

    public HLString des;

    public HLString value;

    public int score;

    public boolean isReach;

    public int showLevel;

    public HLImage icon;

    public void Load() {

    }

    public static HLList GetAchievements() {
        HLList achievements = new HLList();
        HLPackage achievement = new HLPackage();
        achievement.Load(new HLString("achievement.pak"));
        HLFile config = new HLFile();
        config.Load1("data.ach");
        int count = config.ReadInt16();
        for (int i = 0; i < count; i++) {
            HLAchievementItem tmpAchievement = new HLAchievementItem();
            tmpAchievement.name = config.ReadString();
            tmpAchievement.showLevel = config.ReadInt8();
            tmpAchievement.score = config.ReadInt16();
            tmpAchievement.value = HLString.ValueOfInt(tmpAchievement.score);
            tmpAchievement.des = config.ReadString();

            achievements.Add(tmpAchievement);
        }
        return achievements;
    }

    public static HLAchievementItem GetAchievement(int id) {
        HLList achievements = GetAchievements();
        return (HLAchievementItem) achievements.GetItem(id - 1);
    }
}
